<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>The small3d library: Image.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="customdoxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo_s.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">The small3d library
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_1bbf6a76ff8eaf46cd48acba40dce3d2.html">small3d</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Image.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_image_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160; </div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;memory&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_logger_8hpp.html">Logger.hpp</a>&quot;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor">#include &lt;png.h&gt;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor">#include &lt;glm/vec4.hpp&gt;</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160; </div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacesmall3d.html">small3d</a> {</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160; </div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="classsmall3d_1_1_image.html">   29</a></span>&#160;  <span class="keyword">class </span><a class="code" href="classsmall3d_1_1_image.html">Image</a> {</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;  <span class="keyword">private</span>:</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160; </div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    <span class="keyword">struct </span>memoryDataAndPos_ {</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;      std::vector&lt;char&gt; data;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;      uint64_t pos = 0;</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;      <span class="keyword">template</span> &lt;<span class="keyword">class</span> Archive&gt;</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;      <span class="keywordtype">void</span> serialize(Archive&amp; archive) {</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;        archive(data, pos);</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;      }</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;    };</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160; </div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    memoryDataAndPos_ memoryDataAndPos;</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160; </div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> width = 0, height = 0;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    std::vector&lt;uint8_t&gt; imageData;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> imageDataSize = 0;</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <span class="keywordtype">void</span> load(<span class="keyword">const</span> std::string fileLocation, std::vector&lt;char&gt;&amp; data);</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">void</span> readDataFromMemory(png_structp png_ptr, png_bytep outBytes,</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;      png_size_t byteCountToRead);</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160; </div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;  <span class="keyword">public</span>:</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160; </div>
<div class="line"><a name="l00056"></a><span class="lineno"><a class="line" href="classsmall3d_1_1_image.html#ae8ebe48834ff700dff0f3f30983b70bd">   56</a></span>&#160;    <span class="keyword">static</span> <span class="keyword">const</span> std::string <a class="code" href="classsmall3d_1_1_image.html#ae8ebe48834ff700dff0f3f30983b70bd">NOTRGBA</a>;</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160; </div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <a class="code" href="classsmall3d_1_1_image.html#afe8aec09a44cfc52975166d930466dea">Image</a>(<span class="keyword">const</span> std::string fileLocation = <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160; </div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    <a class="code" href="classsmall3d_1_1_image.html#afe8aec09a44cfc52975166d930466dea">Image</a>(std::vector&lt;char&gt;&amp; data);</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160; </div>
<div class="line"><a name="l00075"></a><span class="lineno"><a class="line" href="classsmall3d_1_1_image.html#afd4336c0afa2ec91f144da3bb17dc9ef">   75</a></span>&#160;    <a class="code" href="classsmall3d_1_1_image.html#afd4336c0afa2ec91f144da3bb17dc9ef">~Image</a>() = <span class="keywordflow">default</span>;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160; </div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classsmall3d_1_1_image.html#a619d1f2f4c5e4e8c973abcd6b7d03aa5">toColour</a>(glm::vec4 colour);</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160; </div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classsmall3d_1_1_image.html#a335588f99053b1f55c15c60c76c26624">getWidth</a>() <span class="keyword">const</span>;</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160; </div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classsmall3d_1_1_image.html#adf097899bb8212b43a6e620ff0d15007">getHeight</a>() <span class="keyword">const</span>;</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160; </div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classsmall3d_1_1_image.html#a2ca91e211b1f2eb978def755cb1821f3">getByteSize</a>() <span class="keyword">const</span>;</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160; </div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;    <span class="keyword">const</span> uint8_t* <a class="code" href="classsmall3d_1_1_image.html#a5d3226c747156c0176eef8082d55753c">getData</a>() <span class="keyword">const</span>;</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160; </div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    <span class="keyword">template</span> &lt;<span class="keyword">class</span> Archive&gt;</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    <span class="keywordtype">void</span> serialize(Archive&amp; archive) {</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;      archive(memoryDataAndPos, width, height, imageData, imageDataSize);</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    }</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160; </div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;  };</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160; </div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;}</div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclasssmall3d_1_1_image_html_a2ca91e211b1f2eb978def755cb1821f3"><div class="ttname"><a href="classsmall3d_1_1_image.html#a2ca91e211b1f2eb978def755cb1821f3">small3d::Image::getByteSize</a></div><div class="ttdeci">unsigned long getByteSize() const</div><div class="ttdoc">Get the size of the image, in bytes.</div><div class="ttdef"><b>Definition:</b> Image.cpp:289</div></div>
<div class="ttc" id="aclasssmall3d_1_1_image_html_a619d1f2f4c5e4e8c973abcd6b7d03aa5"><div class="ttname"><a href="classsmall3d_1_1_image.html#a619d1f2f4c5e4e8c973abcd6b7d03aa5">small3d::Image::toColour</a></div><div class="ttdeci">void toColour(glm::vec4 colour)</div><div class="ttdoc">Convert to a coloured 10 x 10 pixel image.</div><div class="ttdef"><b>Definition:</b> Image.cpp:60</div></div>
<div class="ttc" id="aclasssmall3d_1_1_image_html_afe8aec09a44cfc52975166d930466dea"><div class="ttname"><a href="classsmall3d_1_1_image.html#afe8aec09a44cfc52975166d930466dea">small3d::Image::Image</a></div><div class="ttdeci">Image(const std::string fileLocation=&quot;&quot;)</div><div class="ttdoc">File-reading constructor.</div><div class="ttdef"><b>Definition:</b> Image.cpp:22</div></div>
<div class="ttc" id="aclasssmall3d_1_1_image_html_ae8ebe48834ff700dff0f3f30983b70bd"><div class="ttname"><a href="classsmall3d_1_1_image.html#ae8ebe48834ff700dff0f3f30983b70bd">small3d::Image::NOTRGBA</a></div><div class="ttdeci">static const std::string NOTRGBA</div><div class="ttdoc">String saying that the colour encoding of the image being read is not RGB/RGBA.</div><div class="ttdef"><b>Definition:</b> Image.hpp:56</div></div>
<div class="ttc" id="anamespacesmall3d_html"><div class="ttname"><a href="namespacesmall3d.html">small3d</a></div><div class="ttdef"><b>Definition:</b> BinaryFile.hpp:15</div></div>
<div class="ttc" id="aclasssmall3d_1_1_image_html_a335588f99053b1f55c15c60c76c26624"><div class="ttname"><a href="classsmall3d_1_1_image.html#a335588f99053b1f55c15c60c76c26624">small3d::Image::getWidth</a></div><div class="ttdeci">unsigned long getWidth() const</div><div class="ttdoc">Get the image width.</div><div class="ttdef"><b>Definition:</b> Image.cpp:281</div></div>
<div class="ttc" id="aclasssmall3d_1_1_image_html"><div class="ttname"><a href="classsmall3d_1_1_image.html">small3d::Image</a></div><div class="ttdoc">An image, loaded from a .png file, which can be used for generating textures.</div><div class="ttdef"><b>Definition:</b> Image.hpp:29</div></div>
<div class="ttc" id="aclasssmall3d_1_1_image_html_a5d3226c747156c0176eef8082d55753c"><div class="ttname"><a href="classsmall3d_1_1_image.html#a5d3226c747156c0176eef8082d55753c">small3d::Image::getData</a></div><div class="ttdeci">const uint8_t * getData() const</div><div class="ttdoc">Get the image data.</div><div class="ttdef"><b>Definition:</b> Image.cpp:293</div></div>
<div class="ttc" id="aclasssmall3d_1_1_image_html_afd4336c0afa2ec91f144da3bb17dc9ef"><div class="ttname"><a href="classsmall3d_1_1_image.html#afd4336c0afa2ec91f144da3bb17dc9ef">small3d::Image::~Image</a></div><div class="ttdeci">~Image()=default</div><div class="ttdoc">Destructor.</div></div>
<div class="ttc" id="aclasssmall3d_1_1_image_html_adf097899bb8212b43a6e620ff0d15007"><div class="ttname"><a href="classsmall3d_1_1_image.html#adf097899bb8212b43a6e620ff0d15007">small3d::Image::getHeight</a></div><div class="ttdeci">unsigned long getHeight() const</div><div class="ttdoc">Get the image height.</div><div class="ttdef"><b>Definition:</b> Image.cpp:285</div></div>
<div class="ttc" id="a_logger_8hpp_html"><div class="ttname"><a href="_logger_8hpp.html">Logger.hpp</a></div><div class="ttdoc">Logger used in small3d.</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.20
</small></address>
</body>
</html>
